﻿Imports System.Data.OracleClient

#Region "Khai báo đối tượng khách hàng"
Public Class KhachHang
    Private s_Ma_dviqly As String
    Private s_Ma_ddoddien As String
    Private s_Ma_ycauknai As Integer
    Private s_Ten_nguoiycau As String
    Private s_Dchi_nguoiycau As String
    Private s_Ngay_tnhan As String
    Private s_Ma_dvidchinh As String
    Public Property Ma_dviqly() As String
        Get
            Return s_Ma_dviqly
        End Get
        Set(ByVal value As String)
            s_Ma_dviqly = value
        End Set
    End Property
    Public Property Ma_ddoddien() As String
        Get
            Return s_Ma_ddoddien
        End Get
        Set(ByVal value As String)
            s_Ma_ddoddien = value
        End Set
    End Property
    Public Property Ma_ycauknai() As Integer
        Get
            Return s_Ma_ycauknai
        End Get
        Set(ByVal value As Integer)
            s_Ma_ycauknai = value
        End Set
    End Property
    Public Property Ten_nguoiycau() As String
        Get
            Return s_Ten_nguoiycau
        End Get
        Set(ByVal value As String)
            s_Ten_nguoiycau = value
        End Set
    End Property
    Public Property Dchi_nguoiycau() As String
        Get
            Return s_Dchi_nguoiycau
        End Get
        Set(ByVal value As String)
            s_Dchi_nguoiycau = value
        End Set
    End Property
    Public Property Ngay_tnhan() As String
        Get
            Return s_Ngay_tnhan
        End Get
        Set(ByVal value As String)
            s_Ngay_tnhan = value
        End Set
    End Property
    Public Property Ma_dvidchinh() As String
        Get
            Return s_Ma_dvidchinh
        End Get
        Set(ByVal value As String)
            s_Ma_dvidchinh = value
        End Set
    End Property
End Class
#End Region

#Region "Các hàm thao tác cho đối tượng khách hàng"
Public Class KhachHangF
    Public Function GetInforOfKhang(ByVal sma_dviqly As String, ByVal ima_ycau_knai As Long) As DataTable
        Dim myProjCnn As New ProjectConnection
        Dim myCnn As New OracleClient.OracleConnection
        Dim myDat As New OracleClient.OracleDataAdapter
        Dim myDtb As New DataTable

        myCnn = myProjCnn.GetConnection_Ora
        myCnn.Open()

        Dim myCmd As New OracleClient.OracleCommand
        With myCmd
            .Connection = myCnn
            .CommandType = CommandType.StoredProcedure
            .CommandText = "PKG_TRACUU_KH.SP_GETDATA_BY_MA_YCAUKNAI"

            .Parameters.Add("p_Ma_dviqly", OracleType.VarChar).Direction = ParameterDirection.Input
            .Parameters("p_Ma_dviqly").Value = sma_dviqly

            .Parameters.Add("p_Ma_ycau_knai", OracleType.Number).Direction = ParameterDirection.Input
            .Parameters("p_Ma_ycau_knai").Value = ima_ycau_knai

            .Parameters.Add("p_Out", OracleType.Cursor).Direction = ParameterDirection.Output
        End With

        myDat = New OracleDataAdapter(myCmd)
        myDat.Fill(myDtb)
        If myDtb.Rows.Count > 0 Then
            Return myDtb
        Else
            Return Nothing
        End If

        myCnn.Close()
    End Function
End Class
#End Region